<?php
require_once ('library/Controller/IController.php');
require_once ('library/Controller/BaseController.php');

/**
 *
 * @author Nguyen
 *        
 */
class IndexController extends BaseController implements IController {
	
	/**
	 */
	public function __construct() {
		parent::__construct ();
	}
	public function testAction() {
		$this->view ()->setHasLayout ( false );
		$this->view ()->setHasView ( false );
		// $parram1 = $this->getParram("_action");
		// $array = array(
		// 'id' => 1,
		// 'name' => 'Nguyen ',
		// 'email' => 'nguyenxvn@gmail.com'
		// );
		// print json_encode($array);
		$date = '2012-10-31 00:00:00';
		iDate::compare ( $date );
	}
	public function changeselloffAction() {
		if ($this->isPost ()) {
			iDebug::debugArray($_REQUEST);
			$id= array();
			$saleoff = array();
 			$i=1;
 			while (isset($_REQUEST['Trip_id'.$i]) ){
 				array_push($id,  $_REQUEST['Trip_id'.$i]);
 				array_push($saleoff,  $_REQUEST['Trip_saleoff'.$i]);
 				$i++;
 			}
 			for ($x =0 ; $x<count($id);$x ++){
 				$trip = new Trip();
 				$this->trip->updateSaleoff($id[$x], $saleoff[$x]);
 			}
 			$url = Config::BASEURL;
 			header ( "Location: " . $url );
		} else {
			$start = (isset($_GET['start']) && (int)$_GET['start'])?$_GET['start']:0;
			$strlimit = 'limit '.$start.',5 ';
			$this->view ()->objectData = $this->trip->gettripandselloff ($strlimit);
		}
	}
	/**
	 * 
	 */
	public function searchAction(){
		$this->view()->setHasLayout(false);
		iDebug::debugArray($this->_model->search());
		$this->view ()->jsonresult = $this->_model->search();
	}
}
?>